package com.visitor.registration.dto;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "统一的API响应格式")
public class ApiResponse<T> {
    
    @Schema(description = "状态码", example = "200")
    private final int code;
    
    @Schema(description = "响应消息", example = "操作成功")
    private final String message;
    
    @Schema(description = "响应数据")
    private final T data;

    private ApiResponse(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }

    public static <T> ApiResponse<T> success(T data) {
        return new ApiResponse<>(200, "操作成功", data);
    }
    
    public static <T> ApiResponse<T> success() {
        return new ApiResponse<>(200, "操作成功", null);
    }
    
    public static <T> ApiResponse<T> error(String message) {
        return new ApiResponse<>(500, message, null);
    }
    
    public static <T> ApiResponse<T> error(int code, String message) {
        return new ApiResponse<>(code, message, null);
    }
} 